import React, { Component } from 'react'; import BasePage from "@/components/Layout/BasePage"; import { addDaftarHadirPeserta, getOneLaporanPublic, signature } from '../../../actions/public'; import { getAutoSave } from "@/actions/autosave"; import ContentWrapper from "@/components/Layout/ContentWrapper"; import { Row, Col, Card, CardBody, Button, Modal, ModalBody, ModalFooter, FormGroup, Input, Navbar, NavItem, NavLink, NavbarBrand } from "reactstrap"; import { Formik, Form, Field, ErrorMessage } from "formik"; import * as Yup from "yup"; import SignatureCanvas from 'react-signature-canvas' import { addPesertaPleno } from '../../../actions/public'; import { toast } from "react-toastify"; import Router from "next/router"; import swal from "sweetalert2"; import Link from 'next/dist/client/link'; import moment from 'moment'; class PlenoSanksi extends Component { constructor(props) { super(props); this.state = { dataLaporan: {}, modal: false, signature: "", nama: "", data: {}, changesign: false, pageDone: false, } } static getInitialProps = async ({ query }) => { return { query }; }; componentDidMount = async () => { const { query } = this.props; const { id } = query; const dataLaporan = await getOneLaporanPublic(id); this.setState({ dataLaporan }); }; toggleModal = (value = true) => { if (!value) { this.setState({ modal: false }); } else { this.setState({ modal: !this.state.modal }); } }; sigPad = [] clear = () => { this.sigPad.clear() } updateValueSignature = () => { const addsig = this.sigPad.getTrimmedCanvas().toDataURL('image/png') this.setState({ signature: addsig, changesign: true }) } updateValueNama = (e) => { this.setState({ nama: e.target.value }); } onSubmit = async (e) => { const { query, token } = this.props; const { id } = query; const sign = this.state.signature const blob = await (await fetch(sign)).blob(); const files = new File([blob], new Date().valueOf() + 'image.png', { type: blob.type }) const formdata = new FormData(); formdata.append("ttd", files); formdata.append("laporan_id", id); formdata.append("nama", this.state.nama); const added = await addDaftarHadirPeserta(token, formdata); const toastid = toast.loading("Please wait..."); if (!added) { swal.fire({ title: "Gagal Input Tanda Tangan", icon: "error", confirmButtonColor: "#3e3a8e", }); } else { swal.fire({ title: "Berhasil Input Tanda Tangan", icon: "success", confirmButtonColor: "#3e3a8e", }); Router.push(`/signature/modul/done/${id}`); } }; render() { const { signature, nama, changesign } = this.state return (
{ this.updateValueNama(e) }} />
{ this.sigPad = ref }} onEnd={(e) => this.setState({ changesign: false })} />

Klik tombol Hadir untuk melakukan tanda tangan sebagai tanda bukti kehadiran rapat

); } } PlenoSanksi.Layout = BasePage; export default PlenoSanksi;